package cn.gdut.chengcai.base;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTimeUtil {
	@SuppressWarnings("deprecation")
	public static Date getStartTime() {
		Date date = new Date();
		Calendar todayStart = Calendar.getInstance();
		todayStart.set(Calendar.YEAR, date.getYear());
		todayStart.set(Calendar.MONTH, date.getMonth());
		todayStart.set(Calendar.DAY_OF_MONTH, date.getDay());
		todayStart.set(Calendar.HOUR, 0);
		todayStart.set(Calendar.MINUTE, 0);
		todayStart.set(Calendar.SECOND, 0);
		todayStart.set(Calendar.MILLISECOND, 0);
		System.out.println(new SimpleDateFormat("yy-MM-dd HH:mm:ss").format(todayStart.getTime()));
		return todayStart.getTime();
	}

	@SuppressWarnings("deprecation")
	public static Date getEndTime() {
		Date date = new Date();
		Calendar todayEnd = Calendar.getInstance();
		todayEnd.set(Calendar.YEAR, date.getYear());
		todayEnd.set(Calendar.MONTH, date.getMonth());
		todayEnd.set(Calendar.DAY_OF_MONTH, date.getDay());
		todayEnd.set(Calendar.HOUR, 23);
		todayEnd.set(Calendar.MINUTE, 59);
		todayEnd.set(Calendar.SECOND, 59);
		todayEnd.set(Calendar.MILLISECOND, 999);
		System.out.println(new SimpleDateFormat("yy-MM-dd HH:mm:ss").format(todayEnd.getTime()));
		return todayEnd.getTime();
	}
}
